package com.lanren.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.lanren.demo.bean.User;
import com.lanren.demo.custom_http.HttpManager;
import com.lanren.easyhttp.callback.SimpleCallBack;
import com.lanren.easyhttp.exception.ApiException;
import com.lanren.easyhttp.utils.HttpLog;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        HttpManager.post("http://10.168.1.195:8081/myfamily/upgrade/check")
//                .params("appVersion", "0.0.3")
//                .execute(new SimpleCallBack<AppUpgradeBean>() {
//                    @Override
//                    public void onError(ApiException e) {
//                        HttpLog.i("+++MainActivity+++" + Thread.currentThread().getName());
//                    }
//
//                    @Override
//                    public void onSuccess(AppUpgradeBean appUpgradeBean) {
//                        HttpLog.i("+++MainActivity+++" + Thread.currentThread().getName());
//                    }
//
//                });
//        HttpManager.post("http://10.168.1.195:8081/myfamily/upgrade/check")
//                .params("appVersion", "0.0.2")
//                .execute(new SimpleCallBack<AppUpgradeBean>() {
//                    @Override
//                    public void onError(ApiException e) {
//                        HttpLog.i("+++MainActivity+++" + Thread.currentThread().getName());
//                    }
//
//                    @Override
//                    public void onSuccess(AppUpgradeBean appUpgradeBean) {
//                        HttpLog.i("+++MainActivity+++" + Thread.currentThread().getName());
//                    }
//
//                });

        findViewById(R.id.test1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test1();
            }
        });

        findViewById(R.id.test2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test2();
            }
        });

    }

    private void test1() {

        HttpManager.post("http://192.168.0.107:8082/MySsm/test/han")
                .params("code", "1")
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {
                        HttpLog.i("+++test 1 onError+++" + Thread.currentThread().getName());
                    }

                    @Override
                    public void onSuccess(String s) {
                        HttpLog.i("+++test 1 onSuccess+++" + GsonUtils.toJson(s));

                    }
                });
    }

    private void test2() {
        HttpManager.post("http://192.168.0.107:8082/MySsm/test/han")
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {
                        HttpLog.i("+++test 2 onError+++" + Thread.currentThread().getName());
                    }

                    @Override
                    public void onSuccess(String s) {
                        HttpLog.i("+++test 2 onSuccess+++" + GsonUtils.toJson(s));

                    }

                });
    }
}
